<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="java.util.HashMap"%>
<%@page import="org.apache.commons.lang.ObjectUtils"%>
<%@page import="java.util.Calendar"%>
<%@page import="java.util.GregorianCalendar"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="org.springframework.web.context.WebApplicationContext"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<%@page import="com.yaodian100.ec.meeting.service.GoogleCalService"%><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="/css/yaodian100backend.css" rel="stylesheet" type="text/css" media="screen" />
<title>预约结果</title>
</head>
<body >
<%
HashMap roomMap = new HashMap();

roomMap.put("100","http://www.google.com/calendar/feeds/jatbqng030nt0jlijc2jb2ogks@group.calendar.google.com/private/full");
roomMap.put("200","http://www.google.com/calendar/feeds/2orgc6hrihtp8519epd7vnfl6o@group.calendar.google.com/private/full");
roomMap.put("300","http://www.google.com/calendar/feeds/cvooetbhg1gtv7r9snrplao4cc@group.calendar.google.com/private/full");
roomMap.put("400","http://www.google.com/calendar/feeds/1v48athesil1l1jpj628tkkcic@group.calendar.google.com/private/full");
roomMap.put("500","http://www.google.com/calendar/feeds/81055k3h2egbo3iimb84k767hs@group.calendar.google.com/private/full");
roomMap.put("600","http://www.google.com/calendar/feeds/qhacmi658sq6rnuni9jo1v2jnc@group.calendar.google.com/private/full");
roomMap.put("700","http://www.google.com/calendar/feeds/gg63bnf85sd81vbk23mkkp28io@group.calendar.google.com/private/full");
roomMap.put("800","http://www.google.com/calendar/feeds/3bd50jlg5ccjgfev58srla1q9g@group.calendar.google.com/private/full");
roomMap.put("900","http://www.google.com/calendar/feeds/naiiphkskuh0lq7luvfh20v4ag@group.calendar.google.com/private/full");

roomMap.put("100M","台北会议室");
roomMap.put("200M","上海办公室-1号");
roomMap.put("300M","上海办公室-2号");
roomMap.put("400M","上海办公室-3号");
roomMap.put("500M","上海办公室-4号");
roomMap.put("600M","上海办公室-5号");
roomMap.put("700M","上海办公室-6号");
roomMap.put("800M","上海办公室-7号");
roomMap.put("900M","上海办公室-8号");

//若增加會議室時加入這個

String subject = request.getParameter("subject") ;
String startdt = request.getParameter("startdate") ;
String starttm = request.getParameter("starttime") ;
String endtm = request.getParameter("endtime") ;
String room = request.getParameter("room") ;
String username = request.getParameter("username") ;

int hh = Integer.parseInt(starttm.split(":")[0]);
int mm = Integer.parseInt(starttm.split(":")[1]);
Calendar calendar = new GregorianCalendar();
java.util.Date date = new java.util.Date(2000,0,1,hh,mm,00);
calendar.setTime(date);
calendar.add(Calendar.MINUTE, Integer.parseInt(endtm));
SimpleDateFormat formatter = new SimpleDateFormat ("HH:mm");
endtm = formatter.format(calendar.getTime());

WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext()); 
GoogleCalService googleService = (GoogleCalService)context.getBean("googleCalService");
googleService.setPassword("Ecyaodian100");
String msg = googleService.addEvent(subject,username,startdt+"T"+starttm+":00.000+08:00",
    startdt+"T"+endtm+":00.000+08:00",ObjectUtils.toString(roomMap.get(room)));
%>
<div align="center">
<script type="text/javascript"><!--
google_ad_client = "pub-2224288299509306";
/* 728x90, 已建立 2008/10/2 */
google_ad_slot = "6109446792";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<BR>
<table width="550" border="0" align="center" ><tr><td>
<table class="tb-data">
  <tr>
    <th width="95" height="28" align=left>会议主题</th>
    <td height="28" align=left><%=subject%></td>
  <tr>
    <th width="95" height="28" align=left>预约人</th>
    <td height="28" align=left><%=username %></td>
  </tr><tr>  
    <th height="28" align=left>会议室</th>
    <td align=left><%=roomMap.get(room+"M")%></td>
  </tr>
  <tr>
    <th height="28" align=left>开始时间</th>
    <td align=left><%=startdt%> <%=starttm%>~<%=endtm%> </td>
    </tr>
  <tr>
    <td height="28" colspan="2" style="text-align:center;"><font color=#ff3300><%=msg %></font></td>
  </tr>
</table>
</td></tr></table>
<BR><div align=center><a href="javascript:history.back();">返回上一頁</a></div>
</body>
</html>